a = 2
def outer():
    global a
    a = a + 1
    print(a)

outer()
print(a)

# 变量写在enclosing 中
#  nonlocal  变量名

def outer():
    a = 3

    def inner():
        nonlocal a
        a = a + 2
        print(a)
    inner()
    print('enclosing',a)
outer()

print('--------><--------')

a = 10
def outer():
    a = 3
    # enclosing

    def inner():
        global a
        a = a + 2
        print('local: ',a)

    inner()
    print('enclosing: ', a)
outer()
print('global: ',a)
